package com.huxiu.holder;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.huxiu.R;
import com.huxiu.SubmitCommentActivity;
import com.huxiu.net.model.CommentItem;
import com.huxiu.net.model.MessageItem;
import com.huxiu.utils.Constants;
import com.huxiu.utils.ImageLoaderOptions;
import com.huxiu.utils.Settings;
import com.huxiu.utils.TextTheam;
import com.huxiu.utils.TextViewUtil;
import com.huxiu.utils.Utils;
import com.huxiu.view.RefreshListView;
import com.huxiu.view.RoundImageView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.lang.ref.WeakReference;


public class MessageHolder implements OnClickListener {
    @ViewInject(R.id.content)
    private TextView content;

    @ViewInject(R.id.time)
    private TextView time;

    private TextViewUtil mTextViewUtil;



    private static Activity mContext;
    private int position = -1;
    private RefreshListView lv_tabdetail_list;
    private static WeakReference<BaseAdapter> mAdapter;

    public void setAdapter(BaseAdapter adapter) {
        mAdapter = new WeakReference<>(adapter);
    }

    public MessageHolder(View view, Context context) {
        ViewUtils.inject(this, view);

        mContext = (Activity) context;
        mTextViewUtil=new TextViewUtil(mContext);
    }

    private MessageItem mItem;

    public void bindItem(MessageItem item){
        mItem = item;

//        if(!TextUtils.isEmpty(mItem.message)&&mItem.message.length()>10){
//            String str=mTextViewUtil.getStringIndex(mItem.message);
//            if(!TextUtils.isEmpty(str)){
//                Log.e("STR", str);
//
//                String mContent=mTextViewUtil.getContent(mItem.message,str);
//                content.setText(mContent);
//                TextTheam.mMessageSetting(str,mContext,content);
//                content.setMovementMethod(LinkMovementMethod.getInstance());
//            }else{
//                Log.e("STR", "str为空");
//                content.setText(mItem.message);
//            }
//        }
        content.setText(mItem.message);
        time.setText(Utils.getDateString(mItem.dateline));
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        }
    }

}
